#include <head.h>

//传递yi
void *Func_1(void *agrc)
{
    char arr[50];
    FILE*fp_1=fopen("源文件","r");
    fseek(fp_1,0,SEEK_SET);
    fread(arr,1,50,fp_1);
    FILE*fp_2=fopen("拷贝文件","w");
    fwrite(arr,1,50,fp_2);
    fclose(fp_1);
    fclose(fp_2);
}

void *Func_2(void *agrc){
    sleep(1);
    char arr[50];
    FILE*fp_1=fopen("源文件","r");
    fseek(fp_1,50,SEEK_SET);
    fread(arr,1,50,fp_1);
    FILE*fp_2=fopen("拷贝文件","a");
    fwrite(arr,1,50,fp_2);
    fclose(fp_1);
    fclose(fp_2);
}


int main(int argc, char const *argv[])
{
    FILE*fp_3=fopen("源文件","w");
    char ch='a';
    for(int i=0;i<100;i++){
        fwrite(&ch,1,1,fp_3);
    }
    fclose(fp_3);
    pthread_t tid_1=0;
    if(0!=pthread_create(&tid_1,NULL,Func_1,NULL))
    {
        printf("线程1创建失败\n");
    }
    pthread_t tid_2=0;
    if(0!=pthread_create(&tid_2,NULL,Func_2,NULL))
    {
        printf("线程2创建失败\n");
    }
    pthread_join(tid_1,NULL);
    pthread_join(tid_2,NULL);
    return 0;
}